package com.book.repository;

import com.book.core.domain.BorrowRecords;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.book.core.vo.BookCategoryLikeVO;
import com.book.core.query.ReadingRankingQuery;
import com.book.core.vo.ReadingStarVO;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
 * @author hongmizfb
 * @description 针对表【borrow_records(图书借阅记录)】的数据库操作Mapper
 * @createDate 2025-05-08 22:32:22
 * @Entity com.book.core.domain.BorrowRecords
 */
@Mapper
public interface BorrowRecordsMapper extends BaseMapper<BorrowRecords> {
    @MapKey("date")
    List<Map<String, Object>> selectBorrowCountByDateRange(@Param("start") Timestamp atStartOfDay, @Param("end") Timestamp atStartOfDay1);

    @MapKey("month_key")
    List<Map<String, Object>> selectBorrowCountByMonth(@Param("start") LocalDateTime atStartOfDay, @Param("end") LocalDateTime atStartOfDay1);

    List<ReadingStarVO> selectUserBorrowPageByDateRange(@Param("start") LocalDateTime startDate,@Param("end") LocalDateTime endTime, @Param("query") ReadingRankingQuery query);
    Long countUserBorrowByDateRange(@Param("start") LocalDateTime start,@Param("end") LocalDateTime endTime );

    /**查询每一本被借过图书的借阅次数
     * @return {@link List }<{@link BookCategoryLikeVO }>
     */
    List<BookCategoryLikeVO> getBookBorrowCount();
}
